package cn.chy.com.main.stuproject.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @Description: TODO
 * @author: 颜淮川
 * @date: 2021年08月16日 14:51
 */
@Configuration // 相当于一个Compent
@EnableSwagger2 // 开始Swagger2
public class SwaggerConfig {

    @Bean
    public Docket docker() {
        return new Docket(DocumentationType.SWAGGER_2).

                apiInfo(getApiInfo()).
                enable(true).
                select().
                apis(RequestHandlerSelectors.basePackage("cn.chy.com.main.controller"))
                .build();
    }

    public ApiInfo getApiInfo() {
        Contact contact = new Contact("颜淮川", "222", "3186475210@qq.com");
        return new ApiInfo(
                "颜淮川的API接口报告",
                "星光不问赶路人，成功不付有心人，熬得住就出众，熬不出就出局",
                "1.0",
                "urn:tos",
                contact, "www.baidu.com",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
}
